package com.yuxiu.edu.web.controller.base;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * @author Administrator
 * @date 2021/1/2 11:43:48
 * @description
 */
public abstract class BaseController<T> {
    public static  String MANAGE_PAGE ;  //管理页面
    public static  String EDIT_PAGE ;   //编辑页面
    public static  String INFO_PAGE ;  //列表页面
    public static  String UPDATE_PAGE ;  //更改页面


    public static final  String  MANAGE = "manage" ;
    public static final  String  EDIT = "edit"  ;
    public static final  String  INFO = "info"  ;
    public static final  String  UPDATE = "update"  ;

    public BaseController(){
        //获取父类带参完整类型
        ParameterizedType type = (ParameterizedType) this.getClass().getGenericSuperclass();
        System.out.println("========="+type);
        //获取参数即模块的类型
        Class<?> modelClass = (Class<?>) type.getActualTypeArguments()[0];
        System.out.println(modelClass);

        //获取小写模块类名
        String modelName = modelClass.getSimpleName().toLowerCase();
        System.out.println(modelName);


        //给静态页面赋值
        MANAGE_PAGE = modelName + "/" + MANAGE ;
        INFO_PAGE = modelName + "/" + INFO;
        EDIT_PAGE = modelName+ "/" + EDIT;
        UPDATE_PAGE = modelName+ "/" +UPDATE  ;
    }
}
